package de.devisnik.eidle.flashlight;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

public class FlashTestView extends ViewPart {

	public void createPartControl(Composite parent) {
		parent.setLayout(new FillLayout());
		Canvas canvas = new Canvas(parent, SWT.NO_REDRAW_RESIZE);
		Star star = new Star(7, 200);
		final Region region = new Region();
		region.add(star.getPointArray(250, 250));
		canvas.addPaintListener(new PaintListener() {

			public void paintControl(PaintEvent e) {
				e.gc.setClipping(region);
				e.gc.drawImage(FlashlightActivator.getDefault().getImageRegistry().get("test_image"), 0, 0);
			}});
	}

	public void setFocus() {
		// TODO Auto-generated method stub

	}

}
